package com.bhs.sansong.adapter;

import android.graphics.Color;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bhs.sansong.R;
import com.bhs.sansong.bean.DiscountCouponBean;
import com.bhs.sansong.utils.MyUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

public class PlatformAdapter extends BaseQuickAdapter<DiscountCouponBean, BaseViewHolder> {

    public PlatformAdapter() {
        super(R.layout.item_platform);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, DiscountCouponBean item) {
        helper.setText(R.id.tv_label, item.getUse_type());
        helper.setText(R.id.tv_money, String.format("%s元券", MyUtils.checkPoint(item.getCoupon_price())));
        helper.setText(R.id.tv_satisfy, String.format("满%s使用", MyUtils.checkPoint(item.getCoupon_min_price())));
        helper.addOnClickListener(R.id.tv_receive_coupon);
        helper.setBackgroundRes(R.id.tv_receive_coupon, item.getCan_take() == 1 ? R.drawable.btn_red_21 : R.drawable.btn_grey_21);
        helper.setTextColor(R.id.tv_receive_coupon, Color.parseColor(item.getCan_take() == 1 ? "#ffffff" : "#909399"));
        helper.setText(R.id.tv_receive_coupon, item.getCan_take() == 1 ? "立即领券" : "已领取");
    }
}
